package com.yy.util.adapter;

import android.content.Context;
import android.util.Base64;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;

import com.yy.util.bitmap.AsyncBitmapHelper;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2015/6/1.
 */
public class CommonAdapter<T> extends BaseAdapter {

    protected Context mContext;
    protected List<T> mData;
    private LayoutInflater mInflater;
    private int mLayoutId;
    private AsyncBitmapHelper mHelper;

    public CommonAdapter(Context context, List<T> data, int layoutId) {
        mContext = context;
        mData = data;
        mLayoutId = layoutId;
        mInflater = LayoutInflater.from(context);
        mHelper = new AsyncBitmapHelper(context);
    }

    @Override
    public int getCount() {
        return mData.size();
    }

    @Override
    public T getItem(int position) {
        return mData.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        final ViewHolder viewHolder = ViewHolder.get(mContext, parent,
                convertView, mLayoutId, position, mHelper);
        convert(viewHolder, getItem(position), position);
        return viewHolder.getConvertView();
    }

    public void convert(ViewHolder viewHolder, T item, int position) {

    }
}